Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:draft report zero state improvements #3363

Merged
merged 6 commits into from
Jan 7, 2025
Merged

fix:draft report zero state improvements #3363

merged 6 commits into from
Jan 7, 2025

Conversation

Sishhhh
Copy link
Contributor

@Sishhhh Sishhhh commented Dec 17, 2024

Clickup

https://app.clickup.com/t/86cx8fb73

Code Coverage

Please add code coverage here

UI Preview

Screenshot 2024-12-17 at 1 11 33 PM Screenshot 2024-12-17 at 1 12 52 PM

Summary by CodeRabbit

  • New Features

    • Updated zero-state display for reports with no expenses, including a new image and dynamic messaging.
    • Introduced a new button for adding expenses with conditional styling based on unreported expenses.
  • Bug Fixes

    • Corrected terminology in the button from "Add complete expenses" to "Add complete expense."
  • Style

    • Added new styles for footer design and zero-state elements, enhancing visual hierarchy and user experience.
  • Tests

    • Enhanced test suite with refined selectors and more detailed assertions for component interactions.

Copy link

coderabbitai bot commented Dec 17, 2024

Walkthrough

The my-view-report.page.html and its associated SCSS file have undergone a dazzling transformation, enhancing the zero-state display for reports without expenses. A fresh image and dynamic messaging now greet users, while buttons for adding expenses have been refined for clarity. The SCSS file introduces new styles for a fixed footer and zero-state elements, elevating the overall visual appeal. The test suite has also been fortified with improved assertions and new test cases, ensuring robust functionality. This is a blockbuster update for expense management!

Changes

File Change Summary
src/app/fyle/my-view-report/my-view-report.page.html - Restructured zero-state display
- Updated expense-related buttons
- Added conditional styling for new "Add new expense" button
src/app/fyle/my-view-report/my-view-report.page.scss - Added new footer container styles
- Introduced zero-state header and image container classes
- Enhanced styling for existing elements
src/app/fyle/my-view-report/my-view-report.page.spec.ts - Updated test setup and assertions
- Altered button selector for more specificity
- Added new test cases for modal interactions

Possibly related PRs

Suggested Labels

size/S

Suggested Reviewers

  • Chethan-Fyle
  • Dimple16

Poem

Expenses dance, zero state fades away,
Buttons sparkle with Rajini's display! 💥
Code transforms with cinematic might,
UI magic takes its stylish flight! 🎬
Reporting just got a superstar's grace! ✨


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the size/M Medium PR label Dec 17, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb9cd69 and a8316dc.

⛔ Files ignored due to path filters (1)
  • src/assets/images/zero-states/invoice.png is excluded by !**/*.png
📒 Files selected for processing (2)
  • src/app/fyle/my-view-report/my-view-report.page.html (1 hunks)
  • src/app/fyle/my-view-report/my-view-report.page.scss (2 hunks)

Comment on lines 59 to 70
&--footer-conatiner {
display: flex;
justify-content: space-between;
padding: 16px;
gap: 8px;
position: fixed;
bottom: 0;
width: 100%;
background-color: $pure-white;
box-shadow: 0 -2px 12px $pink-shadow;
z-index: 999;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Mind it! Let's optimize the footer container styles, macha!

The footer container styling needs some improvements:

  1. Using z-index: 999 is like using a cannon to kill a mosquito! A lower value would suffice.
  2. Fixed positioning with 100% width might cause issues on smaller screens.
  &--footer-conatiner {
    display: flex;
    justify-content: space-between;
    padding: 16px;
    gap: 8px;
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: $pure-white;
    box-shadow: 0 -2px 12px $pink-shadow;
-   z-index: 999;
+   z-index: 10;
+   max-width: 100vw;
+   box-sizing: border-box;
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
&--footer-conatiner {
display: flex;
justify-content: space-between;
padding: 16px;
gap: 8px;
position: fixed;
bottom: 0;
width: 100%;
background-color: $pure-white;
box-shadow: 0 -2px 12px $pink-shadow;
z-index: 999;
}
&--footer-conatiner {
display: flex;
justify-content: space-between;
padding: 16px;
gap: 8px;
position: fixed;
bottom: 0;
width: 100%;
background-color: $pure-white;
box-shadow: 0 -2px 12px $pink-shadow;
z-index: 10;
max-width: 100vw;
box-sizing: border-box;
}

Comment on lines 366 to 378
&--zero-state-semibold-header {
font-size: 14px;
display: block;
color: $blue-black;
line-height: 1.5;
font-weight: 400;
}

&--zero-state-image-container {
height: 150px;
width: 150px;
overflow: hidden;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Style pandratha style-a pandrom! (Let's style it with style!)

The zero state image container needs to be more responsive:

  &--zero-state-image-container {
-   height: 150px;
-   width: 150px;
+   height: min(150px, 30vh);
+   width: min(150px, 90%);
    overflow: hidden;
+   margin: 0 auto;
+   display: flex;
+   align-items: center;
+   justify-content: center;
+   
+   img {
+     max-width: 100%;
+     height: auto;
+   }
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
&--zero-state-semibold-header {
font-size: 14px;
display: block;
color: $blue-black;
line-height: 1.5;
font-weight: 400;
}
&--zero-state-image-container {
height: 150px;
width: 150px;
overflow: hidden;
}
&--zero-state-semibold-header {
font-size: 14px;
display: block;
color: $blue-black;
line-height: 1.5;
font-weight: 400;
}
&--zero-state-image-container {
height: min(150px, 30vh);
width: min(150px, 90%);
overflow: hidden;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
img {
max-width: 100%;
height: auto;
}
}

Comment on lines 179 to 192
<div class="view-reports--footer-conatiner">
<button
*ngIf="unreportedExpenses && unreportedExpenses.length > 0"
class="view-reports--unreported-cta"
class="btn-primary"
(click)="showAddExpensesToReportModal()"
>
Add complete expenses
Add complete expense
</button>
<button
class="btn-outline-secondary"
[ngClass]="{'btn-primary': !(unreportedExpenses && unreportedExpenses.length > 0), 'btn-outline-secondary': unreportedExpenses && unreportedExpenses.length > 0}"
(click)="addExpense()"
>
Add new expense
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Thalaiva style button improvements needed!

The button section needs some improvements:

  1. The button text "Add complete expense" is not very clear. Consider "Add existing expense" instead.
  2. The ngClass condition can be simplified.
- <button
-   class="btn-outline-secondary"
-   [ngClass]="{'btn-primary': !(unreportedExpenses && unreportedExpenses.length > 0), 'btn-outline-secondary': unreportedExpenses && unreportedExpenses.length > 0}"
-   (click)="addExpense()"
- >
-   Add new expense
- </button>
+ <button
+   [class]="unreportedExpenses?.length ? 'btn-outline-secondary' : 'btn-primary'"
+   (click)="addExpense()"
+ >
+   Create new expense
+ </button>

Also, consider extracting the unreportedExpenses check to a getter in the component:

get hasUnreportedExpenses(): boolean {
  return this.unreportedExpenses?.length > 0;
}

Comment on lines +173 to +178
<div class="view-reports--zero-state-image-container">
<img src="../../../assets/images/zero-states/invoice.png" alt="No expense in this report" />
</div>
<div class="view-reports--zero-state-semibold-header">Looks like you’ve got</div>
<div class="view-reports--zero-state-header">0 expense right now</div>
</div>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Kabali da! The zero state looks good, but let's make it perfect!

The alt text could be more descriptive for better accessibility.

- <img src="../../../assets/images/zero-states/invoice.png" alt="No expense in this report" />
+ <img src="../../../assets/images/zero-states/invoice.png" alt="Empty report state - No expenses have been added to this report yet" />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div class="view-reports--zero-state-image-container">
<img src="../../../assets/images/zero-states/invoice.png" alt="No expense in this report" />
</div>
<div class="view-reports--zero-state-semibold-header">Looks like youve got</div>
<div class="view-reports--zero-state-header">0 expense right now</div>
</div>
<div class="view-reports--zero-state-image-container">
<img src="../../../assets/images/zero-states/invoice.png" alt="Empty report state - No expenses have been added to this report yet" />
</div>
<div class="view-reports--zero-state-semibold-header">Looks like you've got</div>
<div class="view-reports--zero-state-header">0 expense right now</div>
</div>

Copy link
Contributor

@Dimple16 Dimple16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sishhhh can you check why unit tests are failing?


&--zero-state-image-container {
height: 150px;
width: 150px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this work for all resolutions of mobile devices?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjunaj5 I have checked it across multiple dimensions, and I think it looks good. At a dimension of 320px, it appears fine as well. Attaching a photo for reference.
Screenshot 2024-12-20 at 5 54 16 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sishhhh, let's share this screenshot with the design team mentioning the resolution.
I think we will need more padding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dimple16 here is the updated ui :

Screen.Recording.2025-01-06.at.12.36.53.PM.mov

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8316dc and 2562483.

📒 Files selected for processing (1)
  • src/app/fyle/my-view-report/my-view-report.page.spec.ts (1 hunks)

Comment on lines 933 to 935
const addExpenseButton = fixture.debugElement.nativeElement.querySelector(
'.view-reports--footer-conatiner .btn-outline-secondary'
) as HTMLElement;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Mind-blowing suggestion: Use data-testid for more stable test selectors!

Hey there! Like a perfectly choreographed action sequence, your tests should be robust and reliable! Instead of relying on complex class-based selectors that can break when styles change, let's add a data-testid attribute to make our test selector more stable, thalaiva style!

-    const addExpenseButton = fixture.debugElement.nativeElement.querySelector(
-      '.view-reports--footer-conatiner .btn-outline-secondary'
-    ) as HTMLElement;
+    const addExpenseButton = fixture.debugElement.nativeElement.querySelector(
+      '[data-testid="add-expense-button"]'
+    ) as HTMLElement;

Don't forget to add the corresponding data-testid attribute to your component template:

<button data-testid="add-expense-button" class="view-reports--footer-conatiner btn-outline-secondary">
  Add Expense
</button>

@Sishhhh Sishhhh requested a review from Dimple16 December 20, 2024 16:29
Copy link
Contributor

@Dimple16 Dimple16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comments


&--zero-state-image-container {
height: 150px;
width: 150px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sishhhh, let's share this screenshot with the design team mentioning the resolution.
I think we will need more padding.

@Sishhhh Sishhhh requested review from Dimple16 and arjunaj5 January 6, 2025 07:09
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a5f53d0 and d1df36c.

📒 Files selected for processing (2)
  • src/app/fyle/my-view-report/my-view-report.page.html (1 hunks)
  • src/app/fyle/my-view-report/my-view-report.page.scss (2 hunks)
🔇 Additional comments (4)
src/app/fyle/my-view-report/my-view-report.page.scss (2)

59-71: Mind it! The footer container needs style optimization, macha!

The footer container styling needs some improvements for better maintainability and responsiveness:

  1. Using z-index: 999 is overkill! A lower value would suffice.
  2. Fixed positioning with 100% width might cause issues on smaller screens.

Apply this diff to optimize the styles:

  &--footer-container {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 8px;
    text-wrap: nowrap;
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: $pure-white;
    box-shadow: 0 -2px 12px $pink-shadow;
-   z-index: 999;
+   z-index: 10;
+   max-width: 100vw;
+   box-sizing: border-box;
  }

374-386: Superstar says: Make the zero state more responsive!

The zero state image container needs to be more responsive:

Apply this improvement:

  &--zero-state-image-container {
-   height: 150px;
-   width: 150px;
+   height: min(150px, 30vh);
+   width: min(150px, 90%);
    overflow: hidden;
+   margin: 0 auto;
+   display: flex;
+   align-items: center;
+   justify-content: center;
+   
+   img {
+     max-width: 100%;
+     height: auto;
+   }
  }
src/app/fyle/my-view-report/my-view-report.page.html (2)

173-178: Kabali da! Let's make the zero state perfect!

The alt text could be more descriptive for better accessibility.

Apply this improvement:

- <img src="../../../assets/images/zero-states/invoice.png" alt="No expense in this report" />
+ <img src="../../../assets/images/zero-states/invoice.png" alt="Empty report state - No expenses have been added to this report yet" />

179-192: Thalaiva style button improvements needed!

The button section needs some improvements:

Apply these changes:

- <button
-   id="add-expense"
-   [ngClass]="{'btn-primary': !(unreportedExpenses && unreportedExpenses.length > 0), 'btn-outline-secondary view-reports--cta': unreportedExpenses && unreportedExpenses.length > 0}"
-   (click)="addExpense()"
- >
-   Add new expense
- </button>
+ <button
+   id="add-expense"
+   [class]="unreportedExpenses?.length ? 'btn-outline-secondary view-reports--cta' : 'btn-primary'"
+   (click)="addExpense()"
+ >
+   Create new expense
+ </button>

Also, consider extracting the unreportedExpenses check to a getter in the component:

get hasUnreportedExpenses(): boolean {
  return this.unreportedExpenses?.length > 0;
}

Comment on lines +73 to +78
&--cta {
font-size: 14px !important;
@media (max-width: 350px) {
font-size: 12px !important;
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Style pandratha style-a pandrom! (Let's style it with style!)

The CTA styles could be improved by:

  1. Avoiding !important declarations
  2. Using CSS custom properties for better maintainability

Consider this improvement:

  &--cta {
-   font-size: 14px !important;
+   font-size: var(--cta-font-size, 14px);
    @media (max-width: 350px) {
-     font-size: 12px !important;
+     --cta-font-size: 12px;
    }
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
&--cta {
font-size: 14px !important;
@media (max-width: 350px) {
font-size: 12px !important;
}
}
&--cta {
font-size: var(--cta-font-size, 14px);
@media (max-width: 350px) {
--cta-font-size: 12px;
}
}

@Sishhhh Sishhhh requested a review from hlkavya0213 January 6, 2025 18:35
}

&--cta {
font-size: 14px !important;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why !important?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the design specifically requires a font size of 14px for this element. However, there is an existing global SCSS rule that sets font-size: 16px !important, removing it could potentially break the design in other parts of the application where the global rule is applied. so i had to override the global rule using 14px !important.

Copy link
Contributor

@hlkavya0213 hlkavya0213 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few comments

@Sishhhh Sishhhh requested a review from hlkavya0213 January 7, 2025 07:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 42a564b and fa91d09.

📒 Files selected for processing (3)
  • src/app/fyle/my-view-report/my-view-report.page.html (1 hunks)
  • src/app/fyle/my-view-report/my-view-report.page.scss (2 hunks)
  • src/app/fyle/my-view-report/my-view-report.page.spec.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (12.x)
🔇 Additional comments (5)
src/app/fyle/my-view-report/my-view-report.page.spec.ts (1)

935-935: Superstar style test improvement, macha!

Using ID selector #add-expense instead of class selector makes the test more robust and reliable.

src/app/fyle/my-view-report/my-view-report.page.scss (3)

396-400: 🧹 Nitpick (assertive)

Make it responsive like a boss!

The zero state image container needs responsive dimensions for better adaptability across different screen sizes.

Apply this diff to make the image container responsive:

  &--zero-state-image-container {
-   height: 150px;
-   width: 150px;
+   height: min(150px, 30vh);
+   width: min(150px, 90%);
    overflow: hidden;
+   margin: 0 auto;
+   display: flex;
+   align-items: center;
+   justify-content: center;
+   
+   img {
+     max-width: 100%;
+     height: auto;
+   }
  }

Likely invalid or redundant comment.


73-78: 🧹 Nitpick (assertive)

Mind it! Let's avoid !important, it's not our style!

Using !important makes styles harder to maintain and override when needed.

Consider using CSS custom properties for better maintainability:

  &--cta {
-   font-size: 14px !important;
+   font-size: var(--cta-font-size, 14px);
    @media (max-width: 350px) {
-     font-size: 12px !important;
+     --cta-font-size: 12px;
    }
  }

Likely invalid or redundant comment.


59-71: 🧹 Nitpick (assertive)

Style pandratha style-a pandrom! (Let's style it with style!)

The footer container styling needs optimization:

  1. z-index: 999 is unnecessarily high
  2. Fixed positioning with 100% width needs constraints for smaller screens

Apply this diff to improve the footer styles:

  &--footer-container {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 8px;
    text-wrap: nowrap;
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: $pure-white;
    box-shadow: 0 -2px 12px $pink-shadow;
-   z-index: 999;
+   z-index: 10;
+   max-width: 100vw;
+   box-sizing: border-box;
  }

Likely invalid or redundant comment.

src/app/fyle/my-view-report/my-view-report.page.html (1)

175-180: 🧹 Nitpick (assertive)

Enhance accessibility like a superstar!

The alt text could be more descriptive for better screen reader experience.

Apply this diff to improve accessibility:

- <img src="../../../assets/images/zero-states/invoice.png" alt="No expense in this report" />
+ <img src="../../../assets/images/zero-states/invoice.png" alt="Empty report state - No expenses have been added to this report yet" />

Likely invalid or redundant comment.

Comment on lines +184 to +194
class="btn-primary view-reports--cta"
(click)="showAddExpensesToReportModal()"
>
Add complete expenses
Add complete expense
</button>
<button
id="add-expense"
[ngClass]="{'btn-primary': !(unreportedExpenses && unreportedExpenses.length > 0), 'btn-outline-secondary view-reports--cta': unreportedExpenses && unreportedExpenses.length > 0}"
(click)="addExpense()"
>
Add new expense
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Simplify the button logic, make it punch dialogues style!

The button implementation needs improvements:

  1. "Add complete expense" is not very clear
  2. Complex ngClass condition can be simplified

Apply these changes to improve clarity and maintainability:

- <button
-   class="btn-primary view-reports--cta"
-   (click)="showAddExpensesToReportModal()"
- >
-   Add complete expense
- </button>
+ <button
+   class="btn-primary view-reports--cta"
+   (click)="showAddExpensesToReportModal()"
+ >
+   Add existing expense
+ </button>

- <button
-   id="add-expense"
-   [ngClass]="{'btn-primary': !(unreportedExpenses && unreportedExpenses.length > 0), 'btn-outline-secondary view-reports--cta': unreportedExpenses && unreportedExpenses.length > 0}"
-   (click)="addExpense()"
- >
-   Add new expense
- </button>
+ <button
+   id="add-expense"
+   [class]="unreportedExpenses?.length ? 'btn-outline-secondary view-reports--cta' : 'btn-primary'"
+   (click)="addExpense()"
+ >
+   Create new expense
+ </button>

Also, consider adding this getter to the component for cleaner template logic:

get hasUnreportedExpenses(): boolean {
  return this.unreportedExpenses?.length > 0;
}

Copy link

github-actions bot commented Jan 7, 2025

Unit Test Coverage % values
Statements 95.96% ( 19295 / 20106 )
Branches 91.11% ( 10660 / 11700 )
Functions 94.24% ( 5735 / 6085 )
Lines 96% ( 18421 / 19188 )

@Sishhhh Sishhhh dismissed Dimple16’s stale review January 7, 2025 11:50

to avoid merging delay

@Sishhhh Sishhhh merged commit f890298 into master Jan 7, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Medium PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants